Skip to content

Bump Android minimum API level from 21 to 24#126838

Merged
simonrozsival merged 17 commits into
dotnet:mainfrom
simonrozsival:dev/simonrozsival/android-bump-min-api-level-to-24
Apr 24, 2026
Merged

Bump Android minimum API level from 21 to 24#126838
simonrozsival merged 17 commits into
dotnet:mainfrom
simonrozsival:dev/simonrozsival/android-bump-min-api-level-to-24

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

@simonrozsival simonrozsival commented Apr 13, 2026

Note

This PR was created with the help of Copilot.

Closes #127265

As part of the move to CoreCLR as the default runtime for .NET on Android, we are raising the minimum supported Android API level from 21 to 24.

Raising the required API level to 24 (Android 7.0 Nougat) allows us to drop several compatibility workarounds that existed solely to support API levels 21–23.

Changes

Minimum API level bump:

  • AndroidApiLevelMin in Directory.Build.props
  • Mirrored defaults in eng/native/build-commons.sh, AndroidBuild.targets, ApkBuilder.cs, and AndroidProject.cs

Removed System.Native getifaddrs shim (introduced in #71943, #76370):

  • Deleted pal_ifaddrs.c / pal_ifaddrs.h — a netlink-based reimplementation of getifaddrs/freeifaddrs that was needed because Bionic didn't include them until API 24
  • Removed the ANDROID_GETIFADDRS_WORKAROUND build flag and runtime dlopen/dlsym fallback in pal_interfaceaddresses.c

Simplified System.Security.Cryptography.Native.Android:

  • Removed the legacy SSLEngineResult.Status enum mapping — ordinal values changed between API 23 and 24 (introduced in [Android] Fix SslStream on Android API 21-23 #94408)
  • Removed the Conscrypt OpenSSLEngineImpl private-field reflection used to access the handshake session on API 21–23; now uses SSLEngine.getHandshakeSession() directly (introduced in [Android] Fix SslStream on Android API 21-23 #78918)
  • Removed the legacy SNI workaround that called internal Conscrypt APIs on API 21–23; now uses SNIHostName/SSLParameters.setServerNames() directly (introduced in [Android] Fix SslStream on Android API 21-23 #78918)
  • Made CertPathValidatorException.getReason(), CertPathValidatorException.BasicReason, PKIXReason, PKIXRevocationChecker, and related cert validation APIs required (available since API 24)

Tests and documentation:

  • Updated OperatingSystemTests to assert API 24 as the minimum
  • Updated Android-related documentation

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Raises the minimum supported Android API level from 21 to 24 to align with the move to CoreCLR as the default runtime on Android, and removes compatibility shims/workarounds that were only needed for API 21–23.

Changes:

  • Bumps Android min API defaults across build props/targets and task defaults (21 → 24).
  • Removes the System.Native getifaddrs workaround/shim previously used for older Android API levels.
  • Simplifies Android crypto/SSL JNI code paths by making API 24+ APIs required and deleting legacy fallback logic.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Directory.Build.props Sets AndroidApiLevelMin to 24 (repo-wide minimum).
eng/native/build-commons.sh Updates native build script default Android API level to 24.
src/mono/msbuild/android/build/AndroidBuild.targets Updates AndroidLibraryMinApiLevel default to 24.
src/tasks/MobileBuildTasks/Android/AndroidProject.cs Updates task-side default min API level to 24.
src/tasks/AndroidAppBuilder/ApkBuilder.cs Updates builder-side default min API level to 24.
src/native/libs/System.Native/pal_interfaceaddresses.c Removes Android getifaddrs workaround code paths and relies on HAVE_GETIFADDRS.
src/native/libs/System.Native/pal_ifaddrs.h (deleted) Deletes the netlink getifaddrs shim header (no longer needed at API 24+).
src/native/libs/System.Native/pal_ifaddrs.c (deleted) Deletes the netlink getifaddrs shim implementation.
src/native/libs/System.Native/CMakeLists.txt Removes the Android workaround definitions and sources for pal_ifaddrs.c.
src/native/libs/System.Security.Cryptography.Native.Android/pal_jni.h Removes Conscrypt private-API globals and makes several JNI APIs non-optional.
src/native/libs/System.Security.Cryptography.Native.Android/pal_jni.c Makes API 24+ JNI types/methods mandatory; removes legacy Conscrypt reflection wiring.
src/native/libs/System.Security.Cryptography.Native.Android/pal_sslstream.c Removes API 21–23 SSLStatus mapping and legacy SNI/handshake-session workarounds.
src/native/libs/System.Security.Cryptography.Native.Android/pal_x509chain.c Requires API 24+ cert validation APIs and simplifies revocation option handling.
src/native/minipal/memorybarrierprocesswide.c Clarifies membarrier comment to specify “older than API 29”.
src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/OperatingSystemTests.cs Updates Android min-version assertion to 24.
src/coreclr/nativeaot/docs/android-bionic.md Updates documentation to reflect min API level is now 24.
docs/workflow/building/coreclr/android.md Updates Android build docs to reflect min API level is now 24.

Comment thread Directory.Build.props
simonrozsival and others added 7 commits April 13, 2026 18:11
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival force-pushed the dev/simonrozsival/android-bump-min-api-level-to-24 branch from 8b65125 to 7c91e8d Compare April 13, 2026 16:11
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

@jkoritzinsky
Copy link
Copy Markdown
Member

This should allow us to fix #111665 I believe.

Comment thread Directory.Build.props
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 14, 2026 21:02
@simonrozsival
Copy link
Copy Markdown
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI review requested due to automatic review settings April 23, 2026 09:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 23 changed files in this pull request and generated no new comments.

@simonrozsival simonrozsival enabled auto-merge (squash) April 24, 2026 11:19
@simonrozsival simonrozsival merged commit ce735b5 into dotnet:main Apr 24, 2026
195 of 200 checks passed
simonrozsival added a commit that referenced this pull request Apr 28, 2026
…7225)

> [!NOTE]
> This PR was created with the assistance of GitHub Copilot.

## Summary

Enable the CoreCLR runtime pack for `android-arm` (armeabi-v7a) by
removing the ARM architecture restriction and adding CI pipeline
support.

## Changes

- **`eng/Subsets.props`** — Remove `arm` from the blocked Android
architectures list (keep `x86` blocked). The original blocker was
`fseeko`/`ftello` not being available below API level 24 (#111665). With
the minimum API level being raised to 24 in #126838, this no longer
applies.
- **`eng/pipelines/runtime.yml`** — Add `android_arm` to the CoreCLR
Android CI platform list.
-
**`eng/pipelines/extra-platforms/runtime-extra-platforms-android.yml`**
— Add `android_arm` to the extra-platforms CoreCLR job.
- **`eng/pipelines/coreclr/templates/helix-queues-setup.yml`** — Add
`android_arm` Helix queue mapping using the same
`Windows.11.Amd64.Android` queues as `android_arm64`.

## What already works (no changes needed)

- Platform matrix definition (`android_arm` already defined in
`platform-matrix.yml`)
- Native build tooling (NDK `arm → armeabi-v7a` mapping)
- Packaging RIDs (`linux-bionic-arm` in `netcoreappRIDs.props` and
`KnownFrameworkReference`)
- Libraries Helix queues (already handle `android_arm`)
- CoreCLR CMake/JIT (no ARM32+Android-specific blocks)

## Dependencies

This PR depends on #126838 (raise `AndroidApiLevelMin` from 21 to 24)
and should be merged after it.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
simonrozsival added a commit to simonrozsival/runtime that referenced this pull request May 11, 2026
Conflict resolutions:

- SslStream.IO.cs / SslStream.Protocol.cs: reconciled main's
  SslStreamPal.CertValidationInCallback gating + split inner overload
  with this branch's 'ref SslPolicyErrors' change. Callers seed
  sslPolicyErrors = SslPolicyErrors.None before VerifyRemoteCertificate
  so the inner overload can accumulate errors without overwriting the
  Android platform-trust verdict.

- Interop.OpenSsl.cs (Linux callback) and FakeSslStream.Implementation.cs:
  updated to the new 'ref SslPolicyErrors' signature.

- pal_sslstream.c: took main's removal of ApplyLegacyAndroidSNIWorkaround
  (legacy API 21-23 code became unreachable after dotnet#126838
  bumped the Android minimum API level to 24). Reverted to 'char*' for
  AndroidCryptoNative_SSLStreamSetTargetHost; further 'const char*' /
  API 21-23 dead-code scrub will land in a follow-up commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
simonrozsival added a commit to simonrozsival/runtime that referenced this pull request May 11, 2026
After dotnet#126838 bumped the Android minimum API level to 24,
the UNSUPPORTED_API_LEVEL return code is unreachable: SNI setup is
supported on every API the runtime can target. The earlier merge
already removed ApplyLegacyAndroidSNIWorkaround; this commit removes
the remaining managed/native plumbing and the now-unused resource
string.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
simonrozsival added a commit to dotnet/android that referenced this pull request May 20, 2026
Enable the CoreCLR runtime flavor for the armeabi-v7a ABI, following the
same pattern as android-arm64 and android-x64.

Changes:
- Set SupportCoreCLR=True for armeabi-v7a in Ndk.projitems.in
- Add ApiLevelNonMono metadata and corresponding property/placeholder
- Add Microsoft.Android.Runtime.CoreCLR.36.1.android-arm to workload manifest

Depends on dotnet/runtime#127225 and dotnet/runtime#126838 (API level 24).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jonathanpeppers added a commit to dotnet/android that referenced this pull request May 20, 2026
dotnet/runtime builds all runtimes (MonoVM, CoreCLR, NativeAOT) against
API level 24. The separate AndroidMinimumNonMonoApiLevel property and all
NonMono-specific API level plumbing in dotnet/android was unnecessary
since MonoVM was already being compiled at API 24 by runtime.

Changes:
- Bump AndroidMinimumDotNetApiLevel from 21 to 24
- Remove AndroidMinimumNonMonoApiLevel and all related properties,
  constants, template placeholders, and conditional logic
- Simplify CMake presets: nonmono-common-* now inherit from common-*
- Remove ArchToApiLevelNonMono dictionary from XABuildConfig
- Simplify MonoAndroidHelper.GetMinimumApiLevel (no runtime branching)
- Remove MinimumNonMonoApiLevel from GenerateSupportedPlatforms task
- Remove runtime-conditional AndroidMinimumSupportedApiLevel items

### Remove nonmono CMake preset indirection

Remove the nonmono-common-* preset definitions (now redundant) and
update all consumers to inherit from common-arm64-v8a / common-x86_64
directly.

Related: dotnet/runtime#126838

### Fix CheckSignApk tests for API 24+ APK signing

With min SDK 24+, apksigner uses v2/v3 signature schemes only and skips
v1 JAR signing, so META-INF/MANIFEST.MF is no longer present in signed
APKs. Replace the ZIP entry check with an AssertApkIsSigned helper that
runs 'apksigner verify' to validate signatures regardless of scheme.

AAB signing still uses jarsigner (which always produces META-INF), so
those assertions are unchanged.

### Remove redist-nativeaot directory; use unified redist for all runtimes

With API level 24 unified across all runtimes, the separate
redist-nativeaot directory (which copied CRT/DSO stubs from the API 24
sysroot) is redundant — the regular redist directory already uses API 24.

Remove the NativeAOT-specific copy in Step_Android_SDK_NDK, point the
NativeAOT pack at the common redist directory, and remove the
redist-nativeaot glob from native.targets.

### Skip BuildXamarinFormsMapsApplication for NativeAOT

R8 9.1.31 crashes with a NullPointerException when processing
androidx.core.core.aar (LocationManagerCompat) in the old AndroidX
packages used by Xamarin.Forms. This only manifests for NativeAOT
because it's the only runtime that runs as Release (which enables R8).

Remove NativeAOT from the test parameters entirely and simplify
the remaining code (IsRelease is always false now).

### Use XamarinAndroidApplicationProject in CheckNothingIsDeletedByIncrementalClean

XamarinFormsAndroidApplicationProject uses old AndroidX packages that
trigger an R8 9.1.31 internal crash (NullPointerException processing
LocationManagerCompat). The test only validates incremental clean
behavior, not Xamarin.Forms-specific functionality.

### Fix NativeAOT runtime pack missing toolchain libraries

The redist-nativeaot removal (cd7f135) accidentally dropped the
toolchain library entries (crtbegin_so.o, crtend_so.o, libc++_static.a,
libc++abi.a, libclang_rt.builtins, libunwind.a) from the NativeAOT
runtime pack. These are required for NativeAOT's native linking step.

Share the toolchain entries between CoreCLR and NativeAOT since both
do native linking. Also consolidate the system lib stubs (libc.so, etc.)
into an unconditional ItemGroup since all runtimes need them.

### Include .o files in NativeAOT runtime pack

The NativeAOT section in native.targets only copied .a files from the
redist directory into the runtime pack, but not .o files (crtbegin_so.o,
crtend_so.o). These CRT object files are needed by the workload-provided
linker (now the default for NativeAOT builds).

Unify the CoreCLR and NativeAOT redist copy blocks since they now use
the same redist directory and need the same file types.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Android] Bump minimum Android API level from 21 to 24 in .NET 11

7 participants